<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>BPLS</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="nivo-slider.css" type="text/css" media="screen" />
<script src="SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script>
<link href="SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="bg">
<div id="logo">
<a href="#"><img src="images/logo_and_name.png" alt="" width="305" height="78" /></a>
		</div>
<div id="main">
<!-- header begins -->
<div id="header">	
	
	<div id="slider-wrapper">        
					             <div id="slider" class="nivoSlider">
									<img src="images/header.jpg" alt="" title="" />
									<img src="images/header2.jpg" alt="" title="" />
									<img src="images/header3.jpg" alt="" title="" />
									<img src="images/header4.jpg" alt="" title="" />									
								</div>        
				            </div>
								
<script type="text/javascript" src="lib/jquery-1.4.3.min.js"></script>
    <script type="text/javascript" src="lib/jquery.nivo.slider.pack.js"></script>
    <script type="text/javascript">
    $(window).load(function() {
        $('#slider').nivoSlider();
    });
    </script>
	
</div>
        <div id="buttons">
		<ul>
			<li class="first"><a href="home.php"  title="">Home</a></li>
			<li><a href="#" title="Business Permit and Licensing System Module">BPLS</a></li>
			<li><a href="#" title="Real Property Tax Module">RPT</a></li>
			<li><a href="#" title="">Contact</a></li>
			<li><a href="#" title="">Help</a></li>
		</ul></div>
<!-- header ends -->
<!-- content begins -->
<div id="content_bg">
    <div id="column_box">
      <div id="bg_left"></div>
      <div id="bg_right"></div>
      <div class="clear"></div>
      
     
    </div>
    <div class="container">
    	<div class="box">
          	<div class="inside">
            	<div class="row-1 outdent">
              	<div class="wrapper">
              	  <div class="meta1">
                  	<div class="box1">
                    	<form name="form1" method="post" action="login2.php">
          <table bordercolor="#333333"width="376" border="5" align="center">
            <tr>
              <td width="358" bg><table width="363" height="136" border="0" align="center" style="align:center;" >
               <tr>
                  <td bgcolor="#666666" height="31" colspan="2" class="ggg"><font color="#00CCFF"><h3>LOGIN:</h3></font></td>
                </tr>
              <?php
			 
			  if(isset($_POST['send2'])){
$db_host = 'localhost';
$db_user = 'root';
$db_password = '';
$db_database_name = 'business-is';
    $connection = new mysqli($db_host, $db_user, $db_password, $db_database_name) or die(mysqli_connect_error());
	 $pass=$_POST['pass2'];
	$query="SELECT * FROM password1 WHERE module='BPLS' && pword='$pass'";
	$query2=$connection->query($query) or die(mysqli_error());
	if((mysqli_num_rows($query2)) > 0){
		$_SESSION['pword']='$password';
		$_SESSION['module']='BPLS';
		
			  ?>
              <script type="text/javascript">        
			  window.location = 'BPLS.php';
    </script>
<?php
	}
	else{
	?>
                <tr>
                  <td height="26" colspan="2" class="hhh"><span class="ddd">INCORRECT PASSWORD</span></td>
                </tr>
                <?PHP
	}
			  }
	?>
               
                <tr>
                  <td width="101" height="30"><span class="hhh">Password:</span></td>
                  <td width="252"><label for="textfield2"></label>
                    <input type="password" name="pass2" id="pass2" size="30"></td>
                </tr>
                <tr>
                  <td rowspan="2">&nbsp;</td>
                  <td style="text-align:right"><input style="height:28;width:70"type="submit" name="send2" id="send2" value="Submit"></td>
                </tr>
                <tr>
                  <td style="text-align:right;font-size:15"><div id="CollapsiblePanel1" class="CollapsiblePanel">
                    <div class="CollapsiblePanelTab" tabindex="0" style="height:25;font-size:15">[change password]</div>
                    <div class="CollapsiblePanelContent">
                    <form method="post" action="login2.php">
                      <table width="252" border="0">
                        <tr>
                          <td colspan="2">&nbsp;</td>
                        </tr>
                        <tr>
                          <td><strong>CURRENT PASSWORD:</strong></td>
                          <td><input type="password" name="current" id="current" size="20"></td>
                        </tr>
                        <tr>
                          <td><strong>NEW PASSWORD:</strong> </td>
                          <td><input type="password" name="new1" id="new1" size="20"></td>
                        </tr>
                        <tr>
                          <td><strong>CONFIRM PASSWORD: </strong></td>
                          <td><input type="password" name="new2" id="new2" size="20"></td>
                        </tr>
                        <tr>
                          <td colspan="2" STYLE="TEXT-align:right"><input type="submit" name="done" id="done" value="Submit"></td>
                        </tr>
                        <tr><td colspan="2"><div align="left">
                        <?php 
                              if(!isset($_POST['send2']) && isset($_POST['done']))
	{
	$curr=$_POST['current'];
	$new1=$_POST['new1'];
	$new2=$_POST['new2'];

	if($current&&$new1&&$new2)
	{
	
	$connect = mysql_connect("localhost","root","") or die("Cannot connect!");
	mysql_select_db("business-is") or die("Couldn't locate database!");

			$query = mysql_query("SELECT * FROM password WHERE module='BPLS' && pword='$current'");
			$numrows = mysql_num_rows($query);
			
			if($numrows!=0){
				if($new1==$new2){
				$update = mysql_query("UPDATE password SET pword='$update_pass' WHERE module='BPLS' && pword='$current'");
				if($update){
				echo '<font color="red"><b>Password changed!</font>';
				}else{
				echo '<font color="red">Unable to change password.</font>';
				}
			}else{
			echo '<font color="red">Passwords didn\'t match.</font>';
			}
		}else{
		echo '<font color="red">Password does not exist</font>';	
	}
}else{
echo '<font color="red">Incomplete data.</font>';
}
}
?>
                        </div>
                        </td></tr>
                      </table>
    </form>
                    </div>
                  </div></td>
                </tr>
              </table></td>
            </tr>
          </table>
 </form>
<script type="text/javascript">
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1");
        </script>
         <br>
        <br>

                      <div class="wrapper"></div>
                     
                    </div>
                  </div>
              	  <div class="meta2">
                  	<div class="box1">
                    	
                                         </div>
                  </div>
              	</div>
              </div>
              <div class="row-2">
              	<div class="wrapper"></div>
              </div>
        </div>
      </div>
    </div>

</div>
<!-- content ends -->
<!-- footer begins -->
<div id="footer">
   <a href="http://validator.w3.org/check?uri=referer">Copyrights © 2012</a> | <a href="http://guinobatan.gov.ph/index.php/guinobatan/index">Municipality of Guinobatan</a>. | All rights reserved. 
      </p></div>
<!-- footer ends -->
</div>
</div>
</body>
</html>